using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
    public partial class vwPlacementTypeComponent
    {
		//
		// TODO: Add constructor logic here
		//

        /// <summary>
        /// Selects all records from the database table.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public List<vwPlacementType> SelectAllWActiveStatus(bool isActive, string sortExpression)
        {
            List<vwPlacementType> listvwPlacementType = new List<vwPlacementType>();
            PlacementManager.DAL.vwPlacementType_DAL o = new PlacementManager.DAL.vwPlacementType_DAL();
            DataSet ds = o.SelectAllWActiveStatus(isActive);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listvwPlacementType.Add(new vwPlacementType((int)row["PlacementTypeId"], (string)row["PlacementTypeName"], (int)row["Year"], (int)row["SemesterId"], (int)row["UnitId"], (int)row["CategoryId"], (int)row["AttendancePatternId"], (int)row["RequiredHours"], (DateTime)row["DateStart"], (DateTime)row["DateEnd"], (DateTime)row["DateCreated"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"], (string)row["UnitCode"], (string)row["UnitName"], (string)row["DivisionName"], (string)row["AttendancePatternName"], (string)row["CategoryName"], (bool)row["IsActive"], (string)row["CampusName"], (int)row["CampusId"], (string)row["CampusCode"]));
            }

            if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated desc";
            }

            listvwPlacementType.Sort(new vwPlacementTypeComparer(sortExpression));
            return listvwPlacementType;
        }
        /// <summary>
        /// Selects all records from the database table.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public List<vwPlacementType> SelectAllWFilters(bool isActive,int unitId, int campusId, int semesterId, int year, int categoryId, string sortExpression)
        {
            List<vwPlacementType> listvwPlacementType = new List<vwPlacementType>();
            PlacementManager.DAL.vwPlacementType_DAL o = new PlacementManager.DAL.vwPlacementType_DAL();
            DataSet ds = o.SelectAllWFilters(isActive,unitId,campusId,semesterId,year,categoryId);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listvwPlacementType.Add(new vwPlacementType((int)row["PlacementTypeId"], (string)row["PlacementTypeName"], (int)row["Year"], (int)row["SemesterId"], (int)row["UnitId"], (int)row["CategoryId"], (int)row["AttendancePatternId"], (int)row["RequiredHours"], (DateTime)row["DateStart"], (DateTime)row["DateEnd"], (DateTime)row["DateCreated"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"], (string)row["UnitCode"], (string)row["UnitName"], (string)row["DivisionName"], (string)row["AttendancePatternName"], (string)row["CategoryName"], (bool)row["IsActive"], (string)row["CampusName"], (int)row["CampusId"], (string)row["CampusCode"]));
            }

            if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated desc";
            }

            listvwPlacementType.Sort(new vwPlacementTypeComparer(sortExpression));
            return listvwPlacementType;
        }

	}
}
